home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / libs / filevirus26alib.lha / examples / fvshow.c < prev   
C/C++ Source or Header  |  1993-03-30  |  2KB  |  75 lines

  1. /* ----------------------------------------------------------------
  2.  *
  3.  *  Project: Filevirus Library
  4.  *
  5.  *  Program: fvshow.c
  6.  *
  7.  *  Author : Bjorn Reese <breese@imada.ou.dk>
  8.  *
  9.  *  Short  : Example showing fvShow(Next)FVInfo.
  10.  *           Compile with "sc LINK fvshow.c"
  11.  *
  12.  * ---------------------------------------------------------------- */
  13.  
  14. #include <stdio.h>
  15.  
  16. #include <exec/types.h>
  17. #include <proto/exec.h>
  18.  
  19. #include <libraries/filevirus.h>
  20. #include <proto/filevirus.h>
  21.  
  22. extern struct Library *SysBase;
  23. struct FilevirusBase *FilevirusBase=NULL;
  24.  
  25. /* ---------------------------------------------------------------- */
  26.  
  27. int main(void)
  28. {
  29.   struct FilevirusNode *p;
  30.   struct FilevirusInfo *pi;
  31.   char *xs;
  32.  
  33.   if ( FilevirusBase = (struct FilevirusBase *)OpenLibrary("filevirus.library", 2) ) {
  34.  
  35.     if ( p = fvAllocNode() ) {
  36.  
  37.       printf("Known viruses [total: %d]\n", FilevirusBase->fb_VInfoTotal);
  38.  
  39.       for ( pi = fvShowFVInfo(p); pi; pi = fvShowNextFVInfo(p) ) {
  40.  
  41.         switch (pi->fvi_Type) {
  42.         case FV_LINK:
  43.           xs = "link";
  44.           break;
  45.         case FV_DELETE:
  46.           xs = "delete";
  47.           break;
  48.         case FV_RENAME:
  49.           xs = "rename";
  50.           break;
  51.         case FV_CODE:
  52.           xs = "code";
  53.           break;
  54.         case FV_OVERLAY:
  55.           xs = "overlay";
  56.           break;
  57.         default:
  58.           xs = "unknown";
  59.           break;
  60.         }
  61.  
  62.         printf(" %4d %-40s (%s)\n", p->fv_VInfoCount, pi->fvi_Name, xs);
  63.  
  64.       }
  65.  
  66.       fvFreeNode(p);
  67.  
  68.     } else fprintf(stderr, "fvAllocNode() failed\n");
  69.  
  70.     CloseLibrary((struct Library *)FilevirusBase);
  71.  
  72.   } else fprintf(stderr, "Cannot open 'filevirus.library'\n");
  73.  
  74. }
  75.